package utils

import (
	"admin/utils/response"
	"github.com/gin-gonic/gin"
	"net/http"
)

func BindJson[T any](c *gin.Context) (T, bool) {
	var req T
	if err := c.ShouldBindJSON(&req); err != nil {
		response.Error(c, http.StatusBadRequest, 4001, err.Error(), "参数错误")
		return req, false
	}
	return req, true
}
